package com.ruoyi.project.system.messagenotice.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.common.utils.uniquekey.IdGererateFactory;
import com.ruoyi.project.system.messagenotice.domain.MessageNotice;
import com.ruoyi.project.system.messagenotice.mapper.MessageNoticeMapper;
import com.ruoyi.project.system.messagenotice.service.IMessageNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 消息通知公告Service业务层处理
 * 
 * @author LCL
 * @date 2021-01-22
 */
@Service
public class MessageNoticeServiceImpl implements IMessageNoticeService 
{
    @Autowired
    private MessageNoticeMapper messageNoticeMapper;
    @Autowired
    private IdGererateFactory idGererateFactory;

    /**
     * 查询消息通知公告
     * 
     * @param id 消息通知公告ID
     * @return 消息通知公告
     */
    @Override
    public MessageNotice selectMessageNoticeById(String id)
    {
        return messageNoticeMapper.selectMessageNoticeById(id);
    }

    /**
     * 查询消息通知公告列表
     * 
     * @param messageNotice 消息通知公告
     * @return 消息通知公告
     */
    @Override
    public List<MessageNotice> selectMessageNoticeList(MessageNotice messageNotice)
    {
        return messageNoticeMapper.selectMessageNoticeList(messageNotice);
    }

    /**
     * 新增消息通知公告
     * 
     * @param messageNotice 消息通知公告
     * @return 结果
     */
    @Override
    public int insertMessageNotice(MessageNotice messageNotice)
    {
        messageNotice.setId(this.idGererateFactory.nextStringId());
        messageNotice.setCreated(DateUtils.getNowDate());
        return messageNoticeMapper.insertMessageNotice(messageNotice);
    }

    /**
     * 修改消息通知公告
     * 
     * @param messageNotice 消息通知公告
     * @return 结果
     */
    @Override
    public int updateMessageNotice(MessageNotice messageNotice)
    {
        return messageNoticeMapper.updateMessageNotice(messageNotice);
    }

    /**
     * 删除消息通知公告对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMessageNoticeByIds(String ids)
    {
        return messageNoticeMapper.deleteMessageNoticeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除消息通知公告信息
     * 
     * @param id 消息通知公告ID
     * @return 结果
     */
    @Override
    public int deleteMessageNoticeById(String id)
    {
        return messageNoticeMapper.deleteMessageNoticeById(id);
    }
}
